package controller

import (
	"context"
	"lot_admin_api/api"
	"lot_admin_api/internal/model"
	"lot_admin_api/internal/service"
)

var Company = cCompany{}

type cCompany struct{}

// ApplyCompany  申请公司信息
func (h *cCompany) ApplyCompany(ctx context.Context, req *api.ApplyCompanyReq) (res *model.CompanyIdRes, err error) {
	id, _ := service.Company().ApplyCompany(ctx, req)
	res = &model.CompanyIdRes{
		Id: id,
	}
	return res, err
}

// DisableCompany 禁用/启动公司信息
func (h *cCompany) DisableCompany(ctx context.Context, req *api.DisableCompanyReq) (res *model.CompanyIdRes, err error) {
	id, _ := service.Company().DisableCompany(ctx, req)
	res = &model.CompanyIdRes{
		Id: id,
	}
	return res, err
}

// CompanyList 公司列表
func (h *cCompany) CompanyList(ctx context.Context, req *api.CompanyListReq) (res *model.CompanyListRes, err error) {
	res, err = service.Company().CompanyList(ctx, req)
	return res, err
}

// UpdateCompany 更新公司信息
func (h *cCompany) UpdateCompany(ctx context.Context, req *api.UpdateCompanyReq) (res *model.CompanyIdRes, err error) {
	id, _ := service.Company().UpdateCompany(ctx, req)
	res = &model.CompanyIdRes{
		Id: id,
	}
	return res, err
}

// CompanyInfo 通过id公司详情
func (h *cCompany) CompanyInfo(ctx context.Context, req *api.CompanyInfoReq) (res *model.CompanyDetailsRes, err error) {
	res, err = service.Company().CompanyInfo(ctx, req.Id);
	return res, err
}

// ExamineCompany  审核公司信息
func (h *cCompany) ExamineCompany(ctx context.Context, req *api.ExamineCompanyReq) (res *model.CompanyIdRes, err error) {
	id, _ := service.Company().ExamineCompany(ctx, req)
	res = &model.CompanyIdRes{
		Id: id,
	}
	return res, err
}
